/*   Copyright © 2009 Mark Gil Torres
 *
 *   This file is part of mtoolkit.
 *
 *   mtoolkit is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   any later version.
 *
 *   mtoolkit is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with mtoolkit.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef VARIANT_HPP
#define VARIANT_HPP

#include <string>
#include <valarray>
#include "../include/q.hpp"
#include "../include/variable.hpp"
#include "../include/term.hpp"
#include "../include/algebraicExpression.hpp"


using namespace mt;

class Variant {
  public:
    Variant(void);
//getter
    char const& getDataType(void);
    int const& getID(void);
    int const& getIValue(void);
    std::string const& getSValue(void);
    Q<int> const& getQIValue(void);
    Variable<Q<int> > const& getVIValue(void);
    Term<Q<int> > const& getTIValue(void);
    AlgebraicExpression<Q<int> > const& getAIValue(void);

//setter
    void setID(int const& inValue);
    void setIValue(int const& inValue);
    void setSValue(std::string const& inValue);
    void setQIValue(Q<int> const& inValue);
    void setVIValue(Variable<Q<int> > const& inValue);
    void setTIValue(Term<Q<int> > const& inValue);
    void setAIValue(AlgebraicExpression<Q<int> > const& inValue);

  private:
    char dataType; // -1 = NULL, 0 = int, 1 = Q<int>, 2 = Variable<Q<int> >, 3 = Term<Q<int> >, 4 = AlgeraicExpression<Q<int> >, 5 = std::string
    int id; // -1 = NULL, 0 = reserve, 1 = VarName, 2 = VarExp, 3 = VarSub, 4 = TermConst, 5 = TermVar, 6 = Term, 7 = AE
    int iValue;
    std::string sValue;
    Q<int> qIValue;
    Variable<Q<int> > vIValue;
    Term<Q<int> > tIValue;
    AlgebraicExpression<Q<int> > aIValue;
};

//constructor
Variant::Variant(void) {
  id = -1;
  dataType = -1;
}

//getter implementation
char const& Variant::getDataType(void) {
  return dataType;
}

int const& Variant::getID(void) {
  return id;
}

int const& Variant::getIValue(void) {
  return iValue;
}

std::string const& Variant::getSValue(void) {
  return sValue;
}

Q<int> const& Variant::getQIValue(void) {
  return qIValue;
}

Variable<Q<int> > const& Variant::getVIValue(void) {
  return vIValue;
}

Term<Q<int> > const& Variant::getTIValue(void) {
  return tIValue;
}

AlgebraicExpression<Q<int> > const& Variant::getAIValue(void) {
  return aIValue;
}

//setter implementation
void Variant::setID(int const& inValue) {
 id = inValue;
}

void Variant::setIValue(int const& inValue) {
  iValue = inValue;
  dataType = 0;
}

void Variant::setSValue(std::string const& inValue) {
  sValue = inValue;
  dataType = 5;
}

void Variant::setQIValue(Q<int> const& inValue) {
  qIValue = inValue;
  dataType = 1;
}

void Variant::setVIValue(Variable<Q<int> > const& inValue) {
  vIValue = inValue;
  dataType = 2;
}

void Variant::setTIValue(Term<Q<int> > const& inValue) {
  tIValue = inValue;
  dataType = 3;
}

void Variant::setAIValue(AlgebraicExpression<Q<int> > const& inValue) {
  aIValue = inValue;
  dataType = 4;
}

#endif
